//! 进程工具
//! 
//! 提供进程管理功能

use std::process::{Command, Child};

/// 执行系统命令
pub fn execute_command(cmd: &str, args: &[&str]) -> Result<String, Box<dyn std::error::Error>> {
    let output = Command::new(cmd)
        .args(args)
        .output()?;
    
    if output.status.success() {
        Ok(String::from_utf8_lossy(&output.stdout).to_string())
    } else {
        Err(format!("命令执行失败: {}", String::from_utf8_lossy(&output.stderr)).into())
    }
}

/// 启动后台进程
pub fn start_background_process(cmd: &str, args: &[&str]) -> Result<Child, Box<dyn std::error::Error>> {
    let child = Command::new(cmd)
        .args(args)
        .spawn()?;
    Ok(child)
}